package com.panda.game.xls.screen;

import com.panda.game.xls.component.MyFont;
import com.panda.game.xls.constant.ScreenConstant;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;

public class TabScreen extends JPanel {

    public TabScreen() {
        super(new GridLayout(1, 1));
        setPreferredSize(new Dimension(ScreenConstant.SCREEN_WIDTH_HALF, ScreenConstant.SCREEN_HEIGHT));

        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.setFont(MyFont.getInstance());
        setTabConten(tabbedPane);
        add(tabbedPane);
    }

    protected static void setTabConten(JTabbedPane tabbedPane) {
//        ImageIcon icon = createImageIcon("tab.jp1g");

        JComponent panel1 = new TabPage1();
        tabbedPane.addTab("主页", null, panel1, "主页");
        tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

        JComponent panel2 = new TabPage2();
        tabbedPane.addTab("充值类型", null, panel2, "设置重置类型");
        tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

        JComponent panel3 = new TabPage3();
        tabbedPane.addTab("员工", null, panel3, "设置员工");
        tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    }

    protected static ImageIcon createImageIcon(String path) {
        java.net.URL imgURL = TabScreen.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("Couldn't find file: " + path);
            return null;
        }
    }

}
